<!--#include file="../core/common/Conn.asp" -->
<!--#include file="../core/common/MD5.asp" -->
<%
	dim action,message
	action = request.QueryString("action")
	message = request.QueryString("message")
	
	if action = "login" then
		call login
	end if
	
	'登录
	sub login
		dim USERNAME,PASSWORD,REMEMBER
		USERNAME = request.Form("USERNAME")
		PASSWORD = request.Form("PASSWORD")
		REMEMBER = request.Form("REMEMBER")
		
		'MD5加密
		PASSWORD = MD5(PASSWORD)

		dim rs,sql
		sql = "select * from USERS where USERNAME = '"& USERNAME &"' and PASSWORD = '"& PASSWORD &"'"
		set rs = db.query(sql)
		if not rs.eof then
			response.Cookies("USERINFO")("USERNAME") = USERNAME
			response.Cookies("USERINFO")("PASSWORD") = PASSWORD
			if REMEMBER = "checked" then
				response.Cookies("USERINFO").expires = date + 30
			end if
			response.Redirect("index.asp")
		else
			message = "您输入的用户名或密码错误！"
		end if
		rs.close
		set rs = nothing
	end sub
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CMSLite for ASP</title>
<link href="resource/css/reset.css" rel="stylesheet" type="text/css" />
<link href="resource/css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="resource/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
	jQuery(function(){
		$("#USERNAME").focus();
	});
</script>
</head>

<body>
<%
	if message <> "" then
		response.Write("<div class=""message"">" & message & "</div>")
	end if
%>
	<form action="?action=login" method="post">
	<div class="login">
		<h1>请登录</h1>
		<p>
			<label for="USERNAME">用户名</label>
			<input type="text" class="textbox" name="USERNAME" id="USERNAME" />
		</p>
		<p>
			<label for="PASSWORD">密码</label>
			<input type="password" class="textbox" name="PASSWORD" id="PASSWORD" />
		</p>
		<p>
			<input type="checkbox" name="REMEMBER" id="REMEMBER" value="checked" />
			<label for="REMEMBER" class="checkbox">保存用户名和密码，以便下一次直接登录</label>
		</p>
		<p>
			<input type="submit" value="登录" class="button" />
		</p>
		<div class="copyright">
			Powered by <a href="#">CMSLite</a> Version 0.1 
		</div>
	</div>
	</form>
</body>
</html>